#include <android/log.h>
//#include <string.h>
#include <jni.h>
#include "com_myapp_JNITest.h"
//#include <asio.hpp>
#include <asio.hpp>
#define DEBUG_TAG "jnitest"

//#include "Server.h"

namespace TEST {

    const char* GetName () {

        return "C++";

    }


    int TwoPlusTwo () {
        return 2 + 5;

    }


    int asiotest(){


    }

};

JNIEXPORT jint JNICALL Java_com_myapp_JNITest_plus( JNIEnv* env, jobject thiz, jint x, jint y )
{
    //__android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK:LC: [%s]", "hello log");


    jstring jstr = env->NewStringUTF("This comes from jni111.中文");
    jclass clazz = env->FindClass("com/myapp/JNITest");
    jmethodID messageMe = env->GetMethodID( clazz, "messageMe", "(Ljava/lang/String;)Ljava/lang/String;");
    jobject result = env->CallObjectMethod(thiz, messageMe, jstr);
    const char* str = env->GetStringUTFChars((jstring) result, NULL); // should be released but what a heck, it's a tutorial :)

    //printf("%s\n", str);

    //__android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "create server\n"); //在logcat中输出  
    //Server net;
    //__android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "init server\n"); //在logcat中输出  
    //net.init();
    //__android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "finish server\n"); //在logcat中输出  

    __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "create ios\n"); //在logcat中输出  
    asio::io_service _ios;
    __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "create acceptor!\n"); //在logcat中输出  

    asio::ip::tcp::acceptor _acceptor(_ios, asio::ip::tcp::endpoint( asio::ip::tcp::v4(), 9543) );
    __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "finish \n"); //在logcat中输出  

    return x+y;

}

